from django.db import models

# Create your models here.


class Account(models.Model):
    """帐户表"""
    username = models.CharField(max_length=64, unique=True)
    email = models.EmailField(unique=True)
    password = models.CharField(max_length=255)
    register_data = models.DateTimeField(auto_now_add=True)
    signature = models.CharField(max_length=255, blank=True, null=True)


class Article(models.Model):
    """文章表"""
    title = models.CharField(max_length=255, unique=True)
    content = models.TextField()
    account = models.ForeignKey('Account', on_delete=models.CASCADE)
    tags = models.ManyToManyField('Tag', null=True)
    pub_date = models.DateField()


class Tag(models.Model):
    """标签表"""
    name = models.CharField(max_length=64, unique=True)
    date = models.DateTimeField(auto_now_add=True)
